
const _import = require('./_import_' + process.env.NODE_ENV)

import Layout from '../views/layout/Layout'
import welcome from '@/views/welcome.vue';
/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/

export const asyncRouterMap = [
  // 平台主页
  {
    path: '/home',
    component: Layout,
    redirect: '/home/index',
    meta: {
      title: 'Home_page', icon: 'dashboard', noCache: true
    },
    children: [{
      path: 'index',
      component: _import('home/index'),
      name: 'home',
      meta: { title: 'Home_page', icon: 'dashboard', noCache: true }
    }]
  },
  // 基本设置
  {
    path: '/setting',
    component: Layout,
    redirect: 'setting',
    alwaysShow: true,
    meta: {
      title: 'General_setting', icon: 'system', noCache: true
    },
    children: [
      {
        path: 'point',
        component: _import('setting/point'),
        name: 'point',
        meta: { title: 'Collected_point_setting', icon: 'system', noCache: true }
      },
      {
        path: 'phone',
        component: _import('setting/phone'),
        name: 'phone',
        meta: { title: 'Contact_number_setting', icon: 'system', noCache: true }
      },
      {
        path: 'page',
        component: _import('setting/page'),
        name: 'page',
        meta: { title: 'Flash_screen_setting', icon: 'system', noCache: true }
      },
      {
        path: 'guide',
        component: _import('setting/guide'),
        name: 'guide',
        meta: { title: 'User_guide', icon: 'system', noCache: true }
      },
      {
        path: 'protocol',
        component: _import('setting/protocol'),
        name: 'protocol',
        meta: { title: 'Service_agreement', icon: 'system', noCache: true }
      },
      {
        path: 'credit',
        component: _import('setting/credit'),
        name: 'credit',
        meta: { title: 'Credit_card_agreement', icon: 'system', noCache: true }
      },
      {
        path: 'privacy',
        component: _import('setting/privacy'),
        name: 'privacy',
        meta: { title: 'Privacy_statement', icon: 'system', noCache: true }
      },
      {
        path: 'coupon',
        component: _import('setting/coupon'),
        name: 'coupon',
        meta: { title: 'Coupon_description', icon: 'system', noCache: true }
      },
      {
        path: 'other',
        component: _import('setting/other'),
        name: 'other',
        meta: { title: 'Others', icon: 'system', noCache: true }
      },
    ]
  },
  // 用户管理
  {
    path: '/user',
    component: Layout,
    redirect: 'user',
    alwaysShow: true,
    meta: { title:'User_management',icon:'peoples',noCache: true},
    children: [
      {
        path: 'list',
        component: _import('user/list'),
        name: 'user_list',
        meta: { title: 'User_list', icon: 'peoples', noCache: true }
      },
      {
        path: 'detail',
        component: _import('user/detail'),
        name: 'user_detail',
        hidden:true,
        meta: { title:'user_detail',icon:'peoples',noCache: true}
      }
    ]
  },
  // 员工管理
  {
    path: '/employee',
    component: Layout,
    redirect: 'employee',
    alwaysShow: true,
    meta: { title:'Staff_management',icon:'peoples',noCache: true},
    children: [
      {
        path: 'list',
        component: _import('employee/list'),
        name: 'employee_list',
        meta: { title: 'Staff_list', icon: 'peoples', noCache: true }
      },
      // {
      //   path: 'detail',
      //   component: _import('administrator/detail'),
      //   name: 'administrator_detail',
      //   hidden:true,
      //   meta: { title:'管理员详情',icon:'peoples',noCache: true}
      // }
    ]
  },
  // 设备管理
  {
    path: '/equipment',
    component: Layout,
    redirect: 'equipment',
    alwaysShow: true,
    meta: { title:'Device_management',icon:'equipment',noCache: true},
    children: [
      {
        path: 'cabinet',
        component: _import('equipment/cabinet'),
        name: 'equipment_cabinet',
        meta: { title: 'Cabinet_management', icon: 'equipment', noCache: true }
      },
      {
        path: 'list',
        component: _import('equipment/list'),
        name: 'equipment_list',
        meta: { title: 'Powerbank_mangement', icon: 'equipment', noCache: true }
      },
    ]
  },
  // 代理管理
  {
    path: '/agent',
    component: Layout,
    redirect: 'agent_join',
    alwaysShow: true,
    meta: { title: 'Agency_management', icon: 'user' },
    children: [
      {
      path: 'join',
      component: _import('agent/join'),
      name: 'agent_join',
      meta: { title: 'Franchise_application_list', icon: 'user', noCache: true },
      },
      {
        path: 'joinDetail',
        component: _import('agent/joinDetail'),
        name: 'join_detail',
        hidden: true,
        meta: { title: 'Franchise_application_detail', icon: 'user', noCache: true },
        },
      {
      path: 'province',
      component: _import('agent/province'),
      name: 'agent_province',
      // hidden: true,
      meta: { title: 'Provincial_State_agency_list', icon: 'user', noCache: true },
      },
      {
      path: 'city',
      component: _import('agent/city'),
      name: 'agent_city',
      // hidden: true,
      // props: (route) => ({ query: route.query.agentId }), 
      meta: { title: 'City_agency_list', icon: 'user', noCache: true }, 
      },
      {
      path: 'channel',
      component: _import('agent/channel'),
      name: 'agent_channel ',
      // hidden: true,
      meta: { title: 'Business_developer_agency', icon: 'user', noCache: true }, 
      },
      {
        path: 'category',
        component: _import('agent/category'),
        name: 'agent_category',
        // hidden: true,
        meta: { title: 'Shop_category_list', icon: 'user', noCache: true }, 
        },
      {
      path: 'store',
      component: _import('agent/store'),
      name: 'agent_store',
      // hidden: true,
      meta: { title: 'Shop_list', icon: 'user', noCache: true }, 
      },
      {
        path: 'storeDetail',
        component: _import('agent/storeDetail'),
        name: 'store_detail',
        hidden: true,
        meta: { title: 'Shop_detail', icon: 'user', noCache: true }, 
      },
      {
        path: 'add',
        component: _import('agent/add'),
        name: 'agent_add',
        hidden: true,
        meta: { title: 'Shop_add', icon: 'user', noCache: true }, 
        },
    ]
  },
  //订单管理
  {
    path: '/equipmentOrders',
    component: Layout,
    redirect: 'equipmentOrders',
    alwaysShow: true,
    meta: { title:'Order_management',icon:'order',noCache: true},
    children: [
      {
        path: 'list',
        component: _import('equipmentOrders/list'),
        name: 'equipmentOrders_list',
        meta: { title: 'Order_List', icon: 'order', noCache: true }
      },
      {
        path: 'detail',
        component: _import('equipmentOrders/detail'),
        name: 'equipmentOrders_detail',
        hidden:true,
        meta: { title:'Order_detail',icon:'order',noCache: true}
      }
    ]
  },
  // 财务管理
  {
    path: '/financial',
    component: Layout,
    redirect: 'financial',
    meta: { title: 'Financial_management', icon: 'financial' },
    children: [
      {
        path: 'order',
        component: _import('financial/order'),
        name: 'financial_order',
        meta: { title: 'Income_order_list', icon: 'financial', noCache: true }
      },
      {
        path: 'getPrice',
        component: _import('financial/getPrice'),
        name: 'financial_getPrice',
        meta: { title: 'Withdrawal_record', icon: 'financial', noCache: true }
      },
      {
        path: 'cabinet',
        component: _import('financial/cabinet'),
        name: 'financial_cabinet',
        meta: { title: 'Device_list', icon: 'financial', noCache: true }
      },
      {
        path: 'normalWithdrawal',
        component: _import('financial/normalWithdrawal'),
        name: 'financial_normalWithdrawal',
        meta: { title: 'Operating_cost', icon: 'financial', noCache: true }
      },
      {
        path: 'withdrawal',
        component: _import('financial/withdrawal'),
        name: 'financial_withdrawal',
        hidden:true,
        meta: { title: 'Operating_cost', icon: 'financial', noCache: true }
      },
      {
        path: 'battery',
        component: _import('financial/battery'),
        name: 'financial_battery',
        hidden:true,
        meta: { title: 'Device_list', icon: 'financial', noCache: true }
      },
      {
        path: 'operating',
        component: _import('financial/operating'),
        name: 'financial_operating',
        meta: { title: 'Income', icon: 'financial', noCache: true }
      },
      {
        path: 'office',
        component: _import('financial/office'),
        name: 'financial_office',
        meta: { title: 'Office', icon: 'financial', noCache: true }
      },
      {
        path: 'addoperating',
        component: _import('financial/addoperating'),
        name: 'financial_addoperating',
        hidden: true,
        meta: { title: 'Income_add', icon: 'financial', noCache: true }
      },
      {
        path: 'back',
        component: _import('financial/back'),
        name: 'financial_back',
        meta: { title: 'Deposit_management', icon: 'financial', noCache: true }

      }
    ]
  },
  // 优惠券管理 
  {
    path: '/coupons',
    component: Layout,
    redirect: '/coupons/list',
    alwaysShow: true,
    meta: { title: 'Coupon_mangement', icon: 'coupon' },
    children: [
      {
        path: 'list',
        component: _import('coupons/list'),
        name: 'coupon_list',
        meta: { title: 'Coupon_List', icon: 'coupon', noCache: true },
      }
    ]
  },
  // 充值管理  topUp
  {
    path: '/topUp',
    component: Layout,
    redirect: '/topUp/list',
    alwaysShow: true,
    meta: { title: 'Top_up_managament', icon: 'recharge' },
    children: [
      {
        path: 'list',
        component: _import('topUp/list'),
        name: 'topUp_list',
        meta: { title: 'Top_up_list', icon: 'recharge', noCache: true },
      },
      {
        path: 'package',
        component: _import('topUp/package'),
        name: 'topUp_package',
        meta: { title: 'Top_up_package', icon: 'recharge', noCache: true },
      }
    ]
  },
  // 推荐管理
  {
   path: '/recommend',
   component: Layout,
   redirect: '/recommend/list',
   alwaysShow: true,
   meta: { title: 'Recommendation_management', icon: 'recommand' },
   children: [
     {
       path: 'list',
       component: _import('recommend/list'),
       name: 'recommend_list',
       meta: { title: 'Recommendation_list', icon: 'recommand', noCache: true },
     },
     {
       path: 'setting',
       component: _import('recommend/setting'),
       name: 'recommend_setting',
       meta: { title: 'Recommendation_setting', icon: 'recommand', noCache: true },   
     }
   ]
 },
  // 意见反馈
  {
    path: '/feedback',
    component: Layout,
    redirect: '/feedback/list',
    alwaysShow: true,
    meta: { title: 'Feedback_management', icon: 'feedback' },
    children: [
      {
        path: 'list',
        component: _import('feedback/list'),
        name: 'feedback_list',
        meta: { title: 'Feedback_list', icon: 'feedback', noCache: true },
      },
      {
        path: 'detail',
        component: _import('feedback/detail'),
        name: 'feedback_detail',
        hidden: true,
        meta: { title: 'Feedback_detail', icon: 'feedback', noCache: true },   
      }
    ]
  },
  // // 系统设置
  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: 'system/tutorial',
  //   alwaysShow: true,
  //   meta: { title: '系统设置', icon: 'user' },
  //   children: [
  //     {
  //       path: 'tutorial',
  //       component: _import('system/tutorial'),
  //       name: 'system_tutorial',
  //       meta: { title: '关于我们', icon: 'system', noCache: true },
  //     },
  //     {
  //       path: 'novice',
  //       component: _import('system/novice'),
  //       name: 'system_novice',
  //       meta: { title: '新手教程', icon: 'system', noCache: true },
  //     },
  //     {
  //       path: 'directions',
  //       component: _import('system/directions'),
  //       name: 'system_directions',
  //       meta: { title: '使用说明', icon: 'system', noCache: true },
  //     },
  //     {
  //       path: 'address',
  //       component: _import('system/address'),
  //       name: 'system_address',
  //       meta: { title: '商城地址设置', icon: 'system', noCache: true },
  //     },
  //     {
  //       path: 'indexPic',
  //       component: _import('system/indexPic'),
  //       name: 'system_indexPic',
  //       meta: { title: '首页轮播图', icon: 'system', noCache: true },
  //     },
  //     {
  //       path: 'color',
  //       component: _import('system/color'),
  //       name: 'system_color',
  //       meta: { title: '小程序设置', icon: 'system', noCache: true },
  //     },
  //   ]
  // },
  // 权限管理
  {
    path: '/management',
    component: Layout,
    redirect: '/management/index',
    hidden: false,
    meta: {
      title: 'Authority_management',
      icon: 'management',
      noCache: true,
    },
    children: [{
        path: 'index',
        component: _import('management/index'),
        name: 'management_role',
        meta: {
          title: 'Position_management',
          icon: 'management',
          noCache: true
        }
      },
      {
        path: 'manager',
        component: _import('management/manager'),
        name: 'management_list',
        meta: {
          title: 'Administrator_management',
          icon: 'management',
          noCache: true
        }
      },
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export const constantRouterMap = [
  {
    path: '/welcome',
    component: Layout,
    redirect: '/welcome/index',
    meta: { title: 'Welome_page', icon: 'dashboard', noCache: true },
    children: [{
      path: 'index',
      component: welcome,
      name: 'welcome',
      meta: { title: 'Welome_page', icon: 'dashboard', noCache: true }
    }]
  },
  { path: '/',redirect: '/login',hidden: true },
  { path: '/login', name: 'login', component: _import('login/index'), hidden: true },
  { path: '/404', name: '404' ,component: _import('errorPage/404'), hidden: true },
  { path: '/401', name: '401', component: _import('errorPage/401'), hidden: true },
]

export const constUrl = [
  ...asyncRouterMap,
  ...constantRouterMap
] 

